﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _07_ReverseDigits
{
    class Program
    {
        static int ReverseDigits(int unreversedNumber)
        {
            int reversedNumber = 0;
            List<int> containerArray = new List<int>();

            while (unreversedNumber > 0)
            {
                int currentDigit = unreversedNumber % 10;
                unreversedNumber /= 10;
                containerArray.Add(currentDigit);              
            }
           
            for (int index = 0; index < containerArray.Count; index++)
            {
                reversedNumber = reversedNumber * 10 + containerArray[index];
            }

            return reversedNumber;
        }

        static void Main(string[] args)
        {
            int number = 123456789;

            Console.WriteLine(ReverseDigits(number));

            int secondNumber = 20560;
            Console.WriteLine();
            Console.WriteLine(ReverseDigits(secondNumber));

        }
    }
}
